//引入
const mysql = require('mysql');
//创建mysql数据库的配置连接
const con = mysql.createConnection({
  host:'localhost',
  port:3306,
  user:'root',
  password:'root',
  database:'demo'
})

//连接
con.connect();

//封装
function myquery(sql){
  return new Promise((resolve,reject)=>{
    con.query(sql,(err,result)=>{
      resolve([err,result])
    })
  })
}

module.exports = myquery;